/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * HeadSchedulerPanel.java
 *
 * Created on Feb 10, 2012, 3:35:59 PM
 */
package ui.panels;

import java.awt.Color;
import java.awt.Font;
import javax.swing.table.DefaultTableCellRenderer;
import manager.DepartmentHeadDriver;
import model.ViewSchedulerTableModel;
import ui.windows.RemedySchedulerFrame;

/**
 *
 * @author viev
 */
public class HeadSchedulerPanel extends javax.swing.JPanel {

    /** Creates new form HeadSchedulerPanel */
    public HeadSchedulerPanel(RemedySchedulerFrame mainFrame) {
        this.mainFrame = mainFrame;
        initComponents();
        includeModel();
    }
    
    private void includeModel() {
        DepartmentHeadDriver driver = (DepartmentHeadDriver) mainFrame.getDriver();
        ViewSchedulerTableModel model = new ViewSchedulerTableModel(driver.showScheduler());
        schedulerTable.setModel(model);
        schedulerTable.setFillsViewportHeight(true);
        schedulerTable.getTableHeader().setFont(new Font(null, Font.BOLD, 11));
        schedulerTable.getTableHeader().setReorderingAllowed(false);
        DefaultTableCellRenderer cellRenderer1 = new DefaultTableCellRenderer();
        cellRenderer1.setHorizontalAlignment(DefaultTableCellRenderer.CENTER);
        cellRenderer1.setBackground(new Color(100, 50, 102));
        cellRenderer1.setForeground(new Color(240, 240, 240));
        DefaultTableCellRenderer cellRenderer2 = new DefaultTableCellRenderer();
        cellRenderer2.setHorizontalAlignment(DefaultTableCellRenderer.CENTER);
        cellRenderer2.setBackground(Color.yellow);
        schedulerTable.getColumnModel().getColumn(0).setPreferredWidth(350);        
        schedulerTable.getColumnModel().getColumn(1).setCellRenderer(cellRenderer1);
        schedulerTable.getColumnModel().getColumn(1).setPreferredWidth(100);
        schedulerTable.getColumnModel().getColumn(2).setCellRenderer(cellRenderer2);
        schedulerTable.getColumnModel().getColumn(2).setPreferredWidth(150); 
        schedulerTable.getColumnModel().getColumn(3).setCellRenderer(cellRenderer2);
        schedulerTable.getColumnModel().getColumn(3).setPreferredWidth(150); 
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    private RemedySchedulerFrame mainFrame;
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        schedulerTable = new javax.swing.JTable();

        setBackground(new java.awt.Color(255, 255, 255));

        jScrollPane1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Scheduler", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Agency FB", 1, 14))); // NOI18N

        schedulerTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(schedulerTable);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 532, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 348, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable schedulerTable;
    // End of variables declaration//GEN-END:variables
}
